﻿using System;
using KKSG;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	// Token: 0x02000F3E RID: 3902
	internal class XPlayerAttributes : XRoleAttributes
	{
		// Token: 0x17003669 RID: 13929
		// (get) Token: 0x0600CFA5 RID: 53157 RVA: 0x00303320 File Offset: 0x00301520
		public override uint ID
		{
			get
			{
				return XPlayerAttributes.uuID;
			}
		}

		// Token: 0x1700366A RID: 13930
		// (get) Token: 0x0600CFA7 RID: 53159 RVA: 0x00303340 File Offset: 0x00301540
		// (set) Token: 0x0600CFA6 RID: 53158 RVA: 0x00303337 File Offset: 0x00301537
		public uint SkillPageIndex { get; set; }

		// Token: 0x0600CFA8 RID: 53160 RVA: 0x00303348 File Offset: 0x00301548
		public XPlayerAttributes()
		{
			this._manualUnitBuff = true;
			this._security_Statistics = new XSecurityStatistics();
		}

		// Token: 0x0600CFA9 RID: 53161 RVA: 0x00303378 File Offset: 0x00301578
		public override void InitAttribute(KKSG.Attribute attr)
		{
			base.InitAttribute(attr);
		}

		// Token: 0x0600CFAA RID: 53162 RVA: 0x00303384 File Offset: 0x00301584
		public bool IsSystemOpened(uint sysID)
		{
			uint num = sysID / 8U;
			int num2 = (int)(sysID % 8U);
			int num3 = 1 << num2;
			bool flag = (ulong)num >= (ulong)((long)this.openedSystem.Length);
			bool result;
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("sys id out of range: ", sysID.ToString(), null, null, null, null);
				result = false;
			}
			else
			{
				result = (((int)this.openedSystem[(int)num] & num3) != 0);
			}
			return result;
		}

		// Token: 0x0600CFAB RID: 53163 RVA: 0x003033EC File Offset: 0x003015EC
		public void CacheOpenSystem(uint sysID)
		{
			bool flag = !XSingleton<XTutorialMgr>.singleton.IsImmediatelyOpenSystem(sysID);
			if (flag)
			{
				XSingleton<XTutorialHelper>.singleton.AddNewOpenSystem(sysID);
				XSingleton<XTutorialMgr>.singleton.SetExternalString("OpenSys" + sysID);
			}
			else
			{
				this.ReallyOpenSystem(sysID);
				bool flag2 = DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.IsVisible();
				if (flag2)
				{
					DlgBase<XMainInterface, XMainInterfaceBehaviour>.singleton.OnSysChange((XSysDefine)sysID);
					XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState((XSysDefine)sysID, true);
				}
			}
		}

		// Token: 0x0600CFAC RID: 53164 RVA: 0x0030346C File Offset: 0x0030166C
		public void ReallyOpenSystem(uint sysID)
		{
			uint num = sysID / 8U;
			int num2 = (int)(sysID % 8U);
			int num3 = 1 << num2;
			bool flag = (ulong)num >= (ulong)((long)this.openedSystem.Length);
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("open sys id out of range: ", sysID.ToString(), null, null, null, null);
			}
			else
			{
				byte[] array = this.openedSystem;
				uint num4 = num;
				array[(int)num4] = (byte)(array[(int)num4] | (byte)num3);
				XSingleton<XGameSysMgr>.singleton.RecalculateRedPointState((XSysDefine)sysID, true);
				XMainInterfaceDocument specificDocument = XDocuments.GetSpecificDocument<XMainInterfaceDocument>(XMainInterfaceDocument.uuID);
				specificDocument.OnSysOpen();
			}
		}

		// Token: 0x0600CFAD RID: 53165 RVA: 0x003034F0 File Offset: 0x003016F0
		public void CloseSystem(uint sysID)
		{
			uint num = sysID / 8U;
			int num2 = (int)(sysID % 8U);
			int num3 = 1 << num2;
			bool flag = (ulong)num >= (ulong)((long)this.openedSystem.Length);
			if (flag)
			{
				XSingleton<XDebug>.singleton.AddErrorLog("close sys id out of range: ", sysID.ToString(), null, null, null, null);
			}
			else
			{
				byte[] array = this.openedSystem;
				uint num4 = num;
				array[(int)num4] = (byte)(array[(int)num4] & (byte)(~(byte)num3));
				XSingleton<XGameSysMgr>.singleton.SetSysRedPointState((XSysDefine)sysID, false);
				XMainInterfaceDocument specificDocument = XDocuments.GetSpecificDocument<XMainInterfaceDocument>(XMainInterfaceDocument.uuID);
				specificDocument.OnSysChange();
			}
		}

		// Token: 0x0600CFAE RID: 53166 RVA: 0x00303574 File Offset: 0x00301774
		public void HPMPReset()
		{
			double attr = base.GetAttr(XAttributeDefine.XAttr_MaxHP_Total);
			base.SetAttr(XAttributeDefine.XAttr_CurrentHP_Basic, attr);
			double attr2 = base.GetAttr(XAttributeDefine.XAttr_MaxMP_Total);
			base.SetAttr(XAttributeDefine.XAttr_CurrentMP_Basic, attr2);
		}

		// Token: 0x0600CFAF RID: 53167 RVA: 0x003035B0 File Offset: 0x003017B0
		public long GetLevelUpExp(int level)
		{
			PlayerLevelTable.RowData byLevel = XSingleton<XEntityMgr>.singleton.LevelTable.GetByLevel(level);
			bool flag = byLevel != null;
			long result;
			if (flag)
			{
				result = byLevel.Exp;
			}
			else
			{
				result = 0L;
			}
			return result;
		}

		// Token: 0x04005D58 RID: 23896
		public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Player_Attributes");

		// Token: 0x04005D59 RID: 23897
		public byte[] openedSystem = new byte[32];

		// Token: 0x04005D5A RID: 23898
		public bool AutoPlayOn = false;
	}
}
